package com.ml.admin.controller;

import com.ml.admin.service.SmsService;
import com.ml.admin.utils.ReturnResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 对接短信平台
 * @author ml
 * @date 2023/3/16 11:21
 */
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsService service;
    /**
     * 对接榛子云平台 发送短信验证码
     * @param phone 手机号
     * @return 成功 or 失败
     */
    @GetMapping("/sendsms")
    public ReturnResponse sendSms(String phone){
        try {
            return service.sendSms(phone);
        } catch (Exception e) {
            e.printStackTrace();
            return ReturnResponse.failure();
        }
    }
}
